package web

import (
	"github.com/gin-gonic/gin"
	uuid "github.com/satori/go.uuid"
	"net/http"
	"testPaper/common"
	"testPaper/model"
	"testPaper/response"
)

// CreatSort 创建试卷分类标签

func CreatSort(c *gin.Context) {
	DB := common.GetDB()
	name := c.PostForm("name")
	testPaperId := c.PostForm("test_paper_id")
	if name == "" {
		response.Reponse(c, http.StatusOK, 422, nil, "标签名不能为空")
		return
	} else if testPaperId == "" {
		response.Reponse(c, http.StatusOK, 422, nil, "试卷id传入不正确")
		return
	}
	sortId := uuid.NewV1().String()

	tag := model.TestPaperSort{
		Name:        name,
		TestPaperId: testPaperId,
		SortId:      sortId,
	}
	DB.Create(&tag)
	response.Reponse(c, http.StatusOK, 200, nil, "创建成功")
	return
}
